GXGetShapeCenter
You can use theGXGetShapeCenter
function to determine the center of a specified contour of a shape.
gxPoint *GXGetShapeCenter(gxShape source, long index, gxPoint *center);
source
- A reference to the shape containing the contour whose center you want to find.
index
- The number of the contour whose center you want to find. You may specify a value of 0 to indicate you want to find the center of the entire shape.
center
- A pointer to a
gxPoint
structure. On return, this structure contains the point that falls at the center of the specified contour.- function result
- The point that falls at the center of the specified contour. (This value is
the same as the value returned in thecenter
parameter.)DESCRIPTION
TheGXGetShapeCenter
function determines the point that falls at the center of the contour specified by theindex
parameter of the shape specified by thesource
parameter. If you specify a value of 0 for theindex
parameter, this function finds the center point of the entire source shape.The center point of a shape is not merely the center of the shape's bounding rectangle; rather it is the "center of gravity" of a shape. QuickDraw GX guarantees the center point of a shape does not change even if the shape is rotated.
This function finds the center of a shape (or of a particular contour) as defined by the source shape's geometry; it does not consider shape fill or transformations to the shape made by the shape's transform. For point shapes, this function returns a copy of the point's geometry. For line and rectangle shapes, this function returns the midpoint of the geometry. For empty and full shapes, this function posts the error
shape_does_not_have_length
.If you provide a target shape that is not one of the geometric shape types, this function performs the actions described in the following table:
Shape type Action taken bitmap Returns midpoint of bounding rectangle picture Posts the error illegal_type_for_shape
text Returns midpoint of the bounding rectangle of the specified glyph glyph Returns midpoint of the bounding rectangle of the specified glyph layout Converts to glyph shape and returns midpoint of the bounding rectangle of the specified glyph ERRORS, WARNINGS, AND NOTICES
Errors out_of_memory shape_is_nil parameter_is_nil (debugging version illegal_type_for_shape (debugging version) contour_less_than_zero (debugging version) graphic_type_does_not_contain_points (debugging version) Warnings contour_out_of_range unable_to_traverse_open_contour_that_starts_or_ends_off_the_curve (debugging version) SEE ALSO
For examples using this function, see "Finding the Bounding Rectangle and Center Point of a Shape" beginning on page 4-43.To find the bounding rectangle of a shape or a contour of a shape, use the
GXGetShapeBounds
function described on page 4-90.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help